<table id ='tables'>
<tr>
<th rowspan=2>STT</th>
<th rowspan=2>Nhân viên</th>
<th rowspan=2>Đội</th>
<th rowspan=2>Địa Điểm</th>
<th rowspan=2>Ngày</th>
<th rowspan=2>Thành viên tham gia</th>
<th colspan=<?php $numhh = count($hanghoas);  echo $numhh?>>Chỉ tiêu</th>
<th rowspan=2>Ghi chú</th>
<th rowspan=2>Thao tác</th>
</tr>
<tr>
<?php foreach ($hanghoas as $keyhh =>$valhh):?>
<th><?php echo $valhh ?></th>
<?php endforeach;?>
</tr>
<?php
	$i=0; 
	 foreach ($chitieungays as $chitieungay):
	  $i++;
?>
<tr>
<td><?php echo $i?></td>
<td><?php echo $chitieungay['Nhanvien']['tennv']?></td>
<td><?php echo $chitieungay['Kehoachbhld']['tendoi']?></td>
<td><?php echo $chitieungay['Kehoachbhld']['diadiem']?></td>
<td><?php echo date('d-m-Y',strtotime($chitieungay['Kehoachbhld']['thoigian']))?></td>
<td><?php echo $chitieungay['Kehoachbhld']['nhansu']?></td>
<?php foreach ($hanghoas as $keyhh =>$valhh):?>
<td>
<?php
	foreach ($chitieungay['Chitieungay'] as $ctngay)
	{
		if($ctngay['hanghoa_id']==$keyhh)
 			echo $ctngay['soluong'];	
	}
?>
</td>
<?php endforeach;?>
<td><?php echo $chitieungay['Kehoachbhld']['ghichu']?></td>
<td>
<?php
$outoftime =0;
$outoftime = date("Y-m-d",strtotime($chitieungay['Kehoachbhld']['thoigian']))>=date('Y-m-d');
?>
<?php if($chitieungay['Kehoachbhld']['nhanvien_id']==$nhanvienht && $outoftime == 1){?>
<?php echo $html->link('Sửa',array('controller'=>'chitieungays','action'=>'suachitieu',$chitieungay['Kehoachbhld']['id']));?>
<?php echo $html->link('Xóa',array('controller'=>'chitieungays','action'=>'xoakehoach',$chitieungay['Kehoachbhld']['id']));?>
<?php }?>
</td>
</tr>
<?php endforeach;?> 
</table>